import requests,json
key = "d3db9101f93fc24ecd64266e51e08f39"
# 地理编码
def geocode(key, address, city=None, batch="false", sig=None, output="json", callback=None):
    geocode_url = "https://restapi.amap.com/v3/geocode/geo?parameters"
    params = {
        "key": key,
        "address": address,
        "city": city,
        "batch": batch,
        "sig": sig,
        "output": output,
        "callback": callback
    }
    r = requests.get(geocode_url, params=params)
    return r.json()


def walk(key, origin, destination, sig=None, output="json", callback=None):
    url = "https://restapi.amap.com/v3/direction/walking?parameters"
    params = {
        "key": key,
        "origin": origin,
        "destination": destination,
        "sig": sig,
        "output": output,
        "callback": callback
    }
    r = requests.get(url, params=params)
    return r.json()
